package away3d.animators ;


import away3d.animators.data.SkeletonAnimationState ;
import away3d.animators.skeleton.SkeletonTreeNode ;
import away3d.errors.AbstractMethodError ;
import flash.geom.Vector3D ;



class SkeletonAnimatorBase extends AnimatorBase
{
    
    
    private var _updateRootPosition : Bool ;
    private var _target             : SkeletonAnimationState ;
    
    
    
    public function new( target: SkeletonAnimationState )
    {
        
        _updateRootPosition     = true ;
        _target                 = target ;
        _target.blendTree       = createBlendTree() ;
        
    }
    
    
    private function createBlendTree() : SkeletonTreeNode
    {
        
        throw new AbstractMethodError() ;
        
    }
    
    
    public function rootDelta( get_rootDelta, null ) : Vector3D< ? >//TODO:
    
    
    public function get_rootDelta() : Vector3D< ? >//TODO:
    {
        
        return _target.blendTree.rootDelta ;
        
    }
    
    
    //TODO: check where override goes before or after private or decide on a format ?
    override private function updateAnimation( realDT: Float, scaledDT: Float )
    {
        
        _target.invalidateState() ;
        
        _target.blendTree.updatePositionData() ;
        
        if( _updateRootPosition )
        {
            
            _target.applyRootDelta() ;
            
        }
        
    }
    
    
    public var updateRootPostion( get_updateRootPosition, set_updateRootPosition ) : Bool ;
    
    
    private function get_updateRootPosition() : Bool
    {
        
        return _updateRootPosition;
        
    }
    
    
    private function set_updateRootPosition( value : Bool ) : Bool
    {
        
        _updateRootPosition = value;
        return value ;
        
    }
    
    
}
